package com.itouch.bracelet.diseaseinfo;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.TextView;

import com.itouch.bracelet.R;
import com.itouch.bracelet.activity.BaseActivity;
import com.itouch.bracelet.bean.DiseaseInfoDetail;
import com.itouch.util.FileTools;

public class DiseaseInfoDetailActivity extends BaseActivity implements OnClickListener{

	TextView tTitle;
	WebView wContent;
	DiseaseInfoDetail detail;
	TextView btn_chat;
	
	@Override
	protected int setContentViewById() {
		
		return R.layout.deseaseinfo_detail;
	}

	@Override
	protected void initViews() {
		// TODO Auto-generated method stub
		tTitle = (TextView) findViewById(R.id.title);
		wContent = (WebView) findViewById(R.id.content);
//		Button btn_back = (Button) findViewById(R.id.back);
//		btn_back.setOnClickListener(this);
		
		
		btn_chat = (TextView) findViewById(R.id.chat);
		btn_chat.setVisibility(View.GONE);
		wContent.getSettings().setDefaultTextEncodingName("UTF-8");
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		Intent intent = getIntent();
		detail = (DiseaseInfoDetail) intent.getSerializableExtra("data");
		tTitle.setText(detail.getTitle() + " (" + detail.getSicktime() + ")");
		
		FileTools.stringWrite2File(getSdcardPath(),
				FileTools.htmlData(detail.getSummary()));
		String url = "file:/" + getSdcardPath();
		wContent.loadUrl(url);
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()) {
//		case R.id.back:
//			finish();
//			break;

		default:
			break;
		}
	}
	
	public String getSdcardPath()
	{
		String path = null;
		String sdcardPath = FileTools.getSdcardDir();
		if(sdcardPath != null)
		{
			path =  sdcardPath + "/diseaseinfo/index.html";
		}
		return path;
	}

}
